05. Demo 2: Hyperparameter Tuning with Random Search

Cd13652 C6 L3 Demo 2 V2

Hyperparameter tuning is critical for optimizing machine learning models. This shootout compares random search and grid search for tuning parameters in a support vector machine model.

  • Setup:

    • Uses a synthetic dataset and support vector machine (SVM).
    • Grid search explored 24 combinations, using six values for the C hyperparameter and four kernel types.
    • Results from the grid search are saved for comparison.
  • Random Search Approach:

    • Instead of trying every combination exhaustively, random search selects random values to explore.
    • Focuses on: C value between 1 and 500 using log-uniform distribution, and kernel choice using discrete uniform distribution.
    • Samples the search space 10 times, a significant reduction from 24 trials in grid search.
  • Performance Comparisons:

    • Random search discovers equally good or better parameter settings in just 30 seconds compared to grid search's three minutes.
    • Highlights the efficiency of random search, especially for large search spaces.

Random search is recommended initially, reserving grid search for finer tuning if necessary.